<template>
  <div class="cbody">
    <el-row :gutter="24" style="padding: 5px 10px;background-color: #f6f6f6">
      <el-col :span="21">
        <el-button type="info" @click="copyBill">复制</el-button>
        <el-button type="success" @click="saveEdit">保存</el-button>
      </el-col>
      <el-col :span="3">
        <el-button-group>
          <el-button type="primary" icon="el-icon-arrow-left" @click="toLast" />
          <el-button type="primary" icon="el-icon-arrow-right" @click="toNext" />
        </el-button-group>
      </el-col>
    </el-row>
    <!-------------------------------表格 ----------------------top ------------------->
    <div class="content">
      <div style="display: flex;justify-content: space-between;margin-right: 10px">
        <div />
        <div>
          <label><input v-model="form.billtype" type="radio" value="生产质检" name="billtype">生产质检</label>
        </div>
        <div>
          <label><input v-model="form.billtype" type="radio" value="最终质检" name="billtype">最终质检</label>
        </div>
        <div>
          <label><input v-model="form.billtype" type="radio" value="半成品" name="billtype">半成品</label>
        </div>
        <div>
          <label><input v-model="form.billtype" type="radio" value="成品" name="billtype">成品</label>
        </div>
        <div>
          抽样标准:GB2828.1-2012
        </div>
      </div>
      <!-------------------------------表格 ----------------------down ------------------->
      <table class="table">
        <thead>
          <tr>
            <td class="topth">
              生产部门
            </td>
            <td> <input v-model="form.cdepname"> </td>
            <td class="topth">
              生产日期
            </td>
            <td><input v-model="form.ddate" type="date"></td>
            <td class="topth">
              需求跟踪号
            </td>
            <td><input v-model="form.csocode"></td>
          </tr>
          <tr>
            <td class="topth">
              产品型号
            </td>
            <td><input v-model="form.csoinvname"></td>
            <td class="topth">
              产品数量
            </td>
            <td><input v-model="form.qcyqty" type="number" class="topth"> /  <input v-model="form.qty" type="number" class="topth"> </td>
            <td class="topth">
              抽样数
            </td>
            <td> <input v-model="form.checkqty" type="number" class="topth"> </td>
          </tr>
        </thead>
      </table>
      <!-------------------------------主信息 ----------------------up ------------------->
      <!-------------------------------下拉选择 ----------------------up ------------------->
      <table class="table">
        <thead>
          <tr>
            <th width="50px" rowspan="3">
              产品要求核对
            </th>
            <th class="mincell" rowspan="2">
              过充
            </th>
            <th class="mincell" rowspan="2">
              过放
            </th>
            <th class="mincell" rowspan="2">
              DC
            </th>
            <th class="mincell" rowspan="2">
              AC
            </th>
            <th class="mincell" rowspan="2">
              S-AC
            </th>
            <th class="mincell" rowspan="2">
              电压
            </th>
            <th class="mincell" rowspan="2">
              电源线
            </th>
            <th class="mincell" rowspan="2">
              充电
            </th>
            <th class="mincell" rowspan="2">
              拉线开关
            </th>
            <th class="mincell" rowspan="2">
              检测开关
            </th>
            <th class="mincell" rowspan="2">
              反光纸
            </th>
            <th class="mincell" rowspan="2">
              防水
            </th>
            <th class="mincell" rowspan="2">
              外置天线
            </th>

            <th class="mincell" colspan="2">
              LED
            </th>
            <th class="mincell" colspan="3">
              电筒功能
            </th>
            <th class="mincell" colspan="2">
              射灯
            </th>
            <th class="mincell" colspan="2">
              电池
            </th>
            <th class="mincell" rowspan="2">
              使用时间
            </th>
            <th class="mincell" colspan="2">
              索件
            </th>
            <th class="mincell" rowspan="2">
              整灯
            </th>
            <th class="mincell" rowspan="2">
              散件
            </th>
          </tr>
          <tr>
            <th class="mincell">
              串
            </th>
            <th class="mincell">
              并
            </th>
            <th class="mincell">
              单
            </th>
            <th class="mincell">
              双
            </th>
            <th class="mincell">
              三
            </th>
            <th class="mincell">
              LED
            </th>
            <th class="mincell">
              灯珠
            </th>
            <th class="mincell">
              片数
            </th>
            <th class="mincell">
              重量
            </th>
            <th class="mincell">
              用料
            </th>
            <th class="mincell">
              颜色配置
            </th>
          </tr>
          <tr>
            <td>
              <select v-model="form.guochong" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.guofang" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dc" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.ac" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.sac" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dianya" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dianyuanxian" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.chondian" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.laxiankaiguan" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.jiancekaiguan" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.fanguangzhi" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.fangshui" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.waizhitianxian" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.ledchuan" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.ledbing" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.diantongdan" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.diantongshuang" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.diantongsan" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.shedengled" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.shedengdanzhu" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dianchipainshu" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dianchizhongliang" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.shiyongshijian" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.suojianyongliao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.suojianyanse" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.zhengdeng" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.sandjian" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
          </tr>
          <tr>
            <th width="50px" rowspan="3">
              包装及丝印核对
            </th>
            <th class="mincell" rowspan="2">
              客户型号
            </th>
            <th class="mincell" rowspan="2">
              品牌
            </th>
            <th class="mincell" rowspan="2">
              光管
            </th>
            <th class="mincell" rowspan="2">
              电池
            </th>
            <th class="mincell" rowspan="2">
              塑件
            </th>
            <th class="mincell" rowspan="2">
              PCS/CN
            </th>
            <th class="mincell" rowspan="2">
              内包装
            </th>
            <th class="mincell" rowspan="2">
              彩盒
            </th>
            <th class="mincell" rowspan="2">
              说明书保修卡等
            </th>
            <th class="mincell" rowspan="2">
              胶袋⌒ 文字 ︶
            </th>
            <th class="mincell" rowspan="2">
              正唛
            </th>
            <th class="mincell" rowspan="2">
              侧唛
            </th>

            <th class="mincell" colspan="8">
              标贴
            </th>
            <th class="mincell" colspan="7" rowspan="2">
              卡通（颜色/字体/文字/封箱胶）
            </th>
          </tr>
          <tr>
            <th class="mincell">
              产地标
            </th>
            <th class="mincell">
              QC标
            </th>
            <th class="mincell">
              电压标
            </th>
            <th class="mincell">
              封口标
            </th>
            <th class="mincell">
              条形标
            </th>
            <th class="mincell">
              认证标
            </th>
            <th class="mincell" colspan="2">
              其它标
            </th>
          </tr>
          <tr>
            <td>
              <select v-model="form.kehuxinghao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.pingpai" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.guangguan" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dianchi" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.suojian" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.pcs" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.neibaozhuang" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.caihe" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.shuomingshu" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.jiaodai" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.zhengsuo" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.cesuo" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.chandibiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.qcbiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.dianyabiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.fengkoubiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.tiaoxingbiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td>
              <select v-model="form.renzhengbiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td colspan="2">
              <select v-model="form.qitabiao" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
            <td colspan="7">
              <select v-model="form.katong" class="cselect">
                <option v-for="(item,index) in options" :key="index" :value="item">{{ item }}</option>
              </select>
            </td>
          </tr>
        </thead>
      </table>
      <!-------------------------------下拉选择 ----------------------up ------------------->
      <!-------------------------------大表格 ----------------------down ------------------->
      <table class="table">
        <tr>
          <th>
            检测项目
          </th>
          <th>
            检测内容
          </th>
          <th width="20px">
            轻缺陷数量
          </th>
          <th width="20px">
            重缺陷数量
          </th>
          <th width="20px">
            致命缺陷数量
          </th>
        </tr>
        <tr>
          <td width="100px" rowspan="3">
            外观
          </td>
          <td>
            <textarea v-model="form.baozhuang" rows="3" cols="60" placeholder="包装：" />
          </td>
          <td>
            <input v-model="form.wgq1" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgz1" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgzm1" type="number" min="0" class="cnumber">
          </td>
        </tr>
        <tr>
          <td>
            <textarea v-model="form.waiguan" rows="3" cols="60" placeholder="外观：" />
          </td>
          <td>
            <input v-model="form.wgq2" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgz2" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgzm2" type="number" min="0" class="cnumber">
          </td>
        </tr>
        <tr>
          <td>
            <textarea v-model="form.jiegouzuzhuang" rows="3" cols="60" placeholder="结构组装：" />
          </td>
          <td>
            <input v-model="form.wgq3" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgz3" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgzm3" type="number" min="0" class="cnumber">
          </td>
        </tr>
        <tr>
          <td width="100px">
            性能
          </td>
          <td>
            <table class="intable">
              <tr>
                <td>充电方式:</td><td><input v-model="form.chongdianfangshi"></td>
              </tr>
              <tr>
                <td>电池批号:</td><td><input v-model="form.dianchipihao"></td>
              </tr>
              <tr>
                <td>充电电流标准:</td><td><input v-model="form.chongdiandianliubiaozhun"></td>
                <td>测试值:</td><td><input v-model="form.ceshi1"></td>
              </tr>
              <tr>
                <td>漏电流标准:</td><td><input v-model="form.loudianliubiaozhun"></td>
                <td>测试值:</td><td><input v-model="form.ceshi2"></td>
              </tr>
              <tr>
                <td>工作电流标准:</td><td><input v-model="form.gongzuodianliubiaozhun"></td>
                <td>测试值:</td><td><input v-model="form.ceshi3"></td>
              </tr>
              <tr>
                <td /><td><input v-model="form.kongbai1"></td>
                <td>测试值:</td><td><input v-model="form.ceshi4"></td>
              </tr>
              <tr>
                <td /><td><input v-model="form.kongbai2"></td>
                <td>测试值:</td><td><input v-model="form.ceshi5"></td>
              </tr>
              <tr>
                <td /><td><input v-model="form.kongbai3"></td>
                <td>测试值:</td><td><input v-model="form.ceshi6"></td>
              </tr>
            </table>
            <textarea v-model="form.gongnengceshi" rows="6" cols="60" placeholder="性能测试：" />
          </td>
          <td>
            <input v-model="form.wgq4" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgz4" type="number" min="0" class="cnumber">
          </td>
          <td>
            <input v-model="form.wgzm4" type="number" min="0" class="cnumber">
          </td>
        </tr>
      </table>
      <!-------------------------------div ----------------------down ------------------->
      <div class="condiv">
        <div class="ditem">
          <div>
            <div class="lditem">
              落地测试：<select v-model="form.downtest" style="width: 200px">
                <option v-for="(item,index) in downtests" :key="index" :value="item">{{ item }}</option>
              </select>
            </div>
            <div class="lditem" style="display: flex">
              <div>高压测试</div>
              <div class="wditem">
                <div><label><input v-model="form.gaoya" name="gaoya" value="1" class="gaoya" type="radio"> 1500V  5mA  3秒</label></div>
                <div><label><input v-model="form.gaoya" name="gaoya" value="2" class="gaoya" type="radio"> 3000V  5mA  3秒  </label></div>
                <div><label><input v-model="form.gaoya" name="gaoya" value="3" class="gaoya" type="radio"> <input v-model="form.gaoyai" type="number" style="width: 60px"> V 5mA  3秒 </label></div>
              </div>
            </div>
            <div>
              <div class="lditem">
                检测水平：<select v-model="form.level" style="width: 200px" @change="changeLevel">
                  <option v-for="(item,index) in levels" :key="index" :value="item">{{ item }}</option>
                </select>
              </div>
              <div class="lditem">
                结果：
                <span class="mditem">A<input v-model="form.jieguoa" class="mditem minp" type="number">台</span>
                <span>B<input v-model="form.jieguob" class="mditem minp" type="number">台</span>
                <span class="mditem">C<input v-model="form.jieguoc" class="mditem minp" type="number">台</span>
              </div>
            </div>
          </div>
          <div>
            <div class="lditem">
              AQL值：
              <span>
                A：<select v-model="form.aqla" style="width: 100px" @change="changeAqla">
                  <option v-for="(item,index) in grades" :key="index" :value="item">{{ item }}</option>
                </select>
              </span>
              <span>
                B：<select v-model="form.aqlb" style="width: 100px" @change="changeAqlb">
                  <option v-for="(item,index) in grades" :key="index" :value="item">{{ item }}</option>
                </select>
              </span>
              <span>
                C：<select v-model="form.aqlc" style="width: 100px" @change="changeAqlc">
                  <option v-for="(item,index) in grades" :key="index" :value="item">{{ item }}</option>
                </select>
              </span>
            </div>
            <div class="lditem" style="display: flex">
              AC/RE值：
              <div class="uspan">
                A:<u>__{{ form.aca }}__/___{{ form.rea }}__</u>
              </div>
              <div class="uspan">
                B:<u>__{{ form.acb }}__/__{{ form.reb }}__</u>
              </div>
              <div class="uspan">
                C:<u>__{{ form.acc }}__/__{{ form.rec }}__</u>
              </div>
            </div>
            <div style="display: flex">
              <div>
                判定：
              </div>
              <div>
                <div>
                  <label class="">合格：<input v-model="form.panding" name="panding" value="合格" type="radio" class="mditem"></label>
                  <label>不合格：<input v-model="form.panding" name="panding" value="不合格" type="radio" class="mditem"></label>
                </div>
                <!--<div>-->
                <!--<label>全检：<input v-model="form.panding" name="panding" value="全检" type="radio" class="mditem"></label>-->
                <!--<label>反工：<input v-model="form.panding" name="panding" value="反工" type="radio" class="mditem"></label>-->
                <!--</div>-->
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="condiv">
        <el-upload
          :action="fileUploadURL"
          list-type="picture-card"
          :on-success="handleUploadSuccess"
          :on-preview="handlePictureCardPreview"
          :on-exceed="handleExceed"
          :limit="6"
          :file-list="filList"
          :on-remove="handleRemove"
        >
          <i class="el-icon-plus" />
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
      </div>
    </div>
  </div>
</template>
<script>
import { finish } from '@/api/rpstock'
import { save } from '@/api/rpstock'
import { get as getStock } from '@/api/rpstock'
import { get } from '@/api/qmilcode'
export default {
  name: 'Qm105e',
  data() {
    return {
      downtests: ['合格', '不合格', '不适用'],
      dialogVisible: false,
      dialogImageUrl: '',
      editVisible: false,
      filList: [],
      fileURL: process.env.VUE_APP_BASE_API,
      fileUploadURL: process.env.VUE_APP_BASE_API + '/file/upload',
      form: {},
      query: {
        sddate: new Date(),
        eddate: new Date(),
        pageIndex: 1,
        pageSize: 10,
        name: ''
      },
      page: [],
      grades: [0, 0.25, 0.4, 0.65, 1.0, 1.5, 2.5, 4.0, 6.5, 10, 15, 25],
      levels: ['S-1', 'S-2', 'S-3', 'S-4', 'I', 'II', 'III'],
      options: ['/', '√', '×'],
      datas: []
    }
  },
  created() {
    if (this.$route.query.id) {
      this.getInCome(this.$route.query.id)
    }
  },
  methods: {
    getInCome(id) {
      this.loading = true
      getStock(id).then(res => {
        this.loading = false
        this.form = res.data.data
        this.filList = []
        for (const image of this.form.images) {
          this.filList.push({ url: this.fileURL + image.imgUrl })
        }
      })
    },
    saveEdit() {
      save(this.form).then(res => {
        if (res.code === 200) {
          this.editVisible = false
          this.$message.success('保存成功!')
        } else {
          this.$message.error(res.medium)
        }
      })
    },
    changeAqla() {
      if (!this.form.level) {
        this.$message({
          showClose: true,
          message: '请检测质检等级',
          type: 'warning'
        })
        return
      }
      if (!this.form.qty) {
        this.$message({
          showClose: true,
          message: '请先填写质检数量',
          type: 'warning'
        })
        return
      }
      if (this.form.aqla === 0) {
        this.form.aca = 0
        this.form.rea = 1
      } else {
        const data = { level: this.form.level, qty: this.form.qty, grade: this.form.aqla }
        get(data).then(res => {
          this.form.aca = res.data.data.ac
          this.form.rea = res.data.data.re
          this.form = JSON.parse(JSON.stringify(this.form))
        })
      }
    },
    copyBill() {
      this.form.id = null
      this.form.images = null
      this.$message.success('复制成功!')
    },
    changeAqlb() {
      if (!this.form.level) {
        this.$message({
          showClose: true,
          message: '请检测质检等级',
          type: 'warning'
        })
        return
      }
      if (!this.form.qty) {
        this.$message({
          showClose: true,
          message: '请先填写质检数量',
          type: 'warning'
        })
        return
      }
      if (this.form.aqlb === 0) {
        this.form.acb = 0
        this.form.reb = 1
      } else {
        const data = { level: this.form.level, qty: this.form.qty, grade: this.form.aqlb }
        get(data).then(res => {
          this.form.acb = res.data.data.ac
          this.form.reb = res.data.data.re
          this.form = JSON.parse(JSON.stringify(this.form))
        })
      }
    },
    changeAqlc() {
      if (!this.form.level) {
        this.$message({
          showClose: true,
          message: '请检测质检等级',
          type: 'warning'
        })
        return
      }
      if (!this.form.qty) {
        this.$message({
          showClose: true,
          message: '请先填写质检数量',
          type: 'warning'
        })
        return
      }
      if (this.form.aqlc === 0) {
        this.form.acc = 0
        this.form.rec = 1
      } else {
        const data = { level: this.form.level, qty: this.form.qty, grade: this.form.aqlc }
        get(data).then(res => {
          this.form.acc = res.data.data.ac
          this.form.rec = res.data.data.re
          this.form = JSON.parse(JSON.stringify(this.form))
        })
      }
    },
    changeLevel() {
      if (this.form.aqla) {
        this.changeAqla()
      }
      if (this.form.aqlb) {
        this.changeAqlb()
      }
      if (this.form.aqlc) {
        this.changeAqlc()
      }
    },
    handleRemove(file, fileList) {
      const images = []
      for (const image of fileList) {
        if (image.response) {
          images.push({ imgUrl: image.response.data.data })
        } else {
          images.push({ imgUrl: image.url.replace(this.fileURL, '') })
        }
      }
      this.form.images = images
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    handleExceed() {
      this.$message({
        showClose: true,
        message: '超出限定图片上传个数',
        type: 'error'
      })
    },
    handleUploadSuccess(res, file, fileList) {
      const images = []
      for (const image of fileList) {
        if (image.response) {
          images.push({ imgUrl: image.response.data.data })
        } else {
          images.push({ imgUrl: image.url.replace(this.fileURL, '') })
        }
      }
      this.form.images = images
    }
  }
}
</script>

<style scoped="css">
  .cbody{
    background-color: #fcfcfc;
  }
  select{
    -webkit-appearance:none;
    -moz-appearance:none;
    appearance:none;
  }
  .content{
    margin: 5px auto;
    width: 900px;
    padding: 20px;
    font-size: 14px;
    font-weight: 400;
    background-color: #f7f7f7;
    text-align: center;
  }
  .topth{
    width: 100px;
  }
  .condiv{
    text-align: left;
    border-width: thin;
    border-color: #c7c7c7;
    border-style: solid;
  }
  .table{
    border-collapse: collapse;
    border-color: #c7c7c7;
  }
  .lditem{
    margin: 15px 0;
  }
  .wditem{
    margin: 0 15px;
  }
  .uspan{
    margin: 0 5px;
  }
  .mditem{
    margin: 0 8px;
  }
  .minp{
    width: 50px;
  }
  td{
    border-style: solid;
    border-width: thin;
    border-color: #c7c7c7;
  }
  .handle-input {
    margin: 10px;
    width: 300px;
    display: inline-block;
  }
  .table {
    width: 100%;
  }
  .mincell{
    width: 20px;
  }
  col2{
    colspan:2
  }
  .cselect{
    height: 20px;
    width: 100%;
    text-align: center;
    border-width: 0;
    background-color: #ffffff;
    font-weight: bold;
  }
  .intable{
    font-size: 8px;
    border-width: 0px;
  }
  th{
    border-style: solid;
    border-width: thin;
    font-weight: 400;
    border-color: #c7c7c7;
  }
  .cnumber{
    width: 90px;
  }
  .ditem{
    padding: 20px;
    display: flex;
    justify-content: space-between;
  }
  .red {
    color: #ff0000;
  }
  .hand-btn {
    margin: 5px;
  }
  .gaoya{
    padding-left: 10px;
  }
</style>
